/*
 * srm 180 div 1 prob 3
 */

import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;


public class Satellites
{
    static double R = 6400;
    
    double[] getCood (String s)
    {
	String[] tmp = s.split ("\\s+");
	double lat = Math.toRadians (Double.parseDouble (tmp[0]));
	double lot = Math.toRadians (Double.parseDouble (tmp[1]));
	double h = 400;
	if (tmp.length == 3)
	    h = Double.parseDouble (tmp[2]);
	h += R;
	double[] cood = new double[4];
	cood[3] = h;
	cood[2] = h*Math.sin (lat);
	cood[0] = h*Math.cos (lat)*Math.sin (lot);
	cood[1] = h*Math.cos (lat)*Math.cos (lot);
	return cood;
    }
    
    double getDis (double[] p1, double[] p2) {
	double ans = 0;
	for (int i = 0; i < 3; ++i)
	    ans += Math.pow (p1[i] - p2[i], 2);
	return Math.sqrt (ans);
    }
    
    double getDis1 (double[] p) {
	double h = p[3];
	return Math.sqrt (h*h - R*R);
    }
    
    boolean isReach (double[] p1, double[] p2) {
	double d = getDis (p1, p2);
	double d1 = getDis1 (p1);
	double d2 = getDis1 (p2);
	return d <= d1 + d2;
    }
    

    public int[] detectable(String[] rs, String[] ss)
    {
	double[][] r = new double[rs.length][4];
	for (int i = 0; i < rs.length; ++i)
	    r[i] = getCood (rs[i]);
	double[][] s = new double[ss.length][4];
	for (int i = 0; i < ss.length; ++i)
	    s[i] = getCood (ss[i]);
	ArrayList<Integer> al = new ArrayList<Integer> ();
	for (int i = 0; i < r.length; ++i) {
	    int num = 0;
	    for (int j = 0; j < s.length; ++j) {
		if (isReach (r[i], s[j]))
		    ++num;
	    }
	    if (num >= 3)
		al.add (i);
	}
	int[] ans = new int[al.size ()];
	for (int i = 0; i < al.size (); ++i)
	    ans[i] = al.get (i);
	return ans;
    }
    
    <%:testing-code%>
}
//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!